<?php
class MostViewQA_Model_SidebarModule extends Zend_Db_Table{
	protected $_name = 'sidebar_module';
	protected $_primary = 'module_id';
	/* Link tham khao : http://framework.zend.com/manual/en/zend.db.table.html */
	/* select demo */
	public function selectModuleByCode($code)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/sidebarmodule/route/selectModuleByCode/code/".$code);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];
		
		return $data;
	}
	public function selectModuleBySortOrder($sort_order)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/sidebarmodule/route/selectModuleBySortOrder2/sort_order/".$sort_order);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];
		
		return $data;
	}	
		
	/* update demo */
	public function updateModule($id,$sort)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restPut("/sidebarmodule/route/updateModule/id/".urlencode($id)."/sort/".urlencode($sort));
		return $return->getBody();		
	}
	
	

	
	
}